package com.yl.auth.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.model.entity.ExcelDictDTO;
import com.yl.auth.model.entity.Yexun;
import com.yl.auth.mapper.YexunMapper;
import com.yl.auth.model.entity.YexunXiao;
import com.yl.auth.model.vo.YexunVo;
import com.yl.auth.model.vo.YexundizhirenyuanVo;
import com.yl.auth.service.YexunService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ln
 * @since 2023-06-15
 */
@Service
public class YexunServiceImpl extends ServiceImpl<YexunMapper, Yexun> implements YexunService {
    @Resource
    private YexunMapper yexunMapper;

    /**
     * 夜巡管理分页添加查询
     * @param iPage
     * @param sname
     * @param sdizhiname
     * @param sinspectiontime
     * @param sinspectionstatus
     * @return
     */
    @Override
    public Page<YexundizhirenyuanVo> getPageVo(Page<YexundizhirenyuanVo> iPage, String sname, String sdizhiname, String sinspectiontime, Integer sinspectionstatus) {
        return yexunMapper.getPageVo(iPage,sname,sdizhiname,sinspectiontime,sinspectionstatus);
    }

    /**
     * 导出
     * @return
     */
    @Override
    public List<ExcelDictDTO> listDictData() {
        List<Yexun> dyexunList = yexunMapper.selectyexun(null);
        //创建ExcelDictDTO列表，将yexun列表转换成ExcelDictDTO列表
        ArrayList<ExcelDictDTO> excelDictDTOList = new ArrayList<>(dyexunList.size());
        dyexunList.forEach(yexun -> {
            ExcelDictDTO excelDictDTO = new ExcelDictDTO();
            BeanUtils.copyProperties(yexun, excelDictDTO);
            excelDictDTOList.add(excelDictDTO);
        });
        return excelDictDTOList;
    }

    @Override
    public List<YexunVo> getyexuns(String sname, String sdizhiname, String sinspectiontime, Integer sinspectionstatus) {
        return yexunMapper.getyexuns(sname, sdizhiname, sinspectiontime, sinspectionstatus);
    }

    @Override
    public List<YexunVo> getxiaoyexuns(Integer id) {
        return yexunMapper.getxiaoyexuns(id);
    }

    @Override
    public List<YexunVo> getyexuntime() {
        return yexunMapper.getyexuntime();
    }

    @Override
    public List<YexunVo> getyexundizhi() {
        return yexunMapper.getyexundizhi();
    }


    @Override
    public List<YexunVo> getzhaungtai(Integer sinspectionstatus) {
        return yexunMapper.getzhaungtai(sinspectionstatus);
    }

    @Override
    public void save(YexunXiao yexunXiao) {
        yexunMapper.save(yexunXiao);
    }

}
